const Router = require("koa-router");
const userController = require("../controllers/userController");
const router = new Router({
    prefix: '/api', // 👈 所有路由自动加 /api 前缀
});
/**
 * @swagger
 * /api/login:
 *   post:
 *     tags:
 *       - User
 *     summary: 用户登录
 *     description: 用户通过用户名和密码登录系统
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             required:
 *               - username
 *               - password
 *             properties:
 *               username:
 *                 type: string
 *                 description: 用户名
 *                 example: root
 *               password:
 *                 type: string
 *                 description: 用户密码
 *                 example: 123456
 *     responses:
 *       200:
 *         description: 登录成功
 *         content:
 *           application/json:
 *             schema:
 *               type: object
 *               properties:
 *                 success:
 *                   type: boolean
 *                   example: true
 *                 message:
 *                   type: string
 *                   example: 登录成功
 *                 token:
 *                   type: string
 *                   example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
 *       400:
 *         description: 参数错误或缺失
 *       401:
 *         description: 用户名或密码错误
 */
router.post('/login', userController.login);
// 创建用户
router.post('/createUser', userController.register);
/** 获取用户列表 */
router.get('/getUserList', userController.getUserList);
/** 修改用户信息 */
router.post('/updateUser', userController.updateUser);

// 获取路由信息
router.get('/getRoute', userController.getRouterInfo);

module.exports = router;